package com.example.java.Service.Impl;

import com.example.java.Entity.Admin;
import com.example.java.Entity.User;
import com.example.java.Mapper.AdminMapper;
import com.example.java.Service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("AdminService")
public class AdminServiceImpl implements AdminService {

    @Autowired
    private AdminMapper adminMapper;

    //    查询所有
    @Override
    public List<Admin> alladmin(){
        return adminMapper.alladmin();
    }

    //    增加
    @Override
    public int addandedit(Admin admin) {
        if (admin.getId() == null) {//如果没有id，则表示新增
            return adminMapper.insert(admin);
        } else {//否则为修改
            return adminMapper.updata(admin);
        }
    }
    //    删除
    @Override
    public int deleteById(Integer id) {
        return adminMapper.deleteById(id);
    }

    //    模糊查询
    @Override
    public List<Admin> getLike(String keyword){
        return adminMapper.getLike(keyword);
    }

}
